from ultralytics import YOLO
import cv2
import glob
import os


# weight_path = r"E:\zhihao\2025文档\25年10月\ai_训练\权重\服务器上的权重\nanshan-fire-v3.pt"
weight_path = r"E:\zhihao\2025文档\25年10月\ai_训练\权重\public_security\traffic_accient\20251016\train89\weights\best.pt"
# 基础路径
base_path = r"E:\zhihao\2025文档\25年10月\ai_训练\视频图片_模型模拟\20251017\模拟模型"
# 自动获取所有jpg图片
image_path = glob.glob(os.path.join(base_path, "*.jpg"))
# 如果需要按数字顺序排序
image_path.sort(key=lambda x: int(os.path.splitext(os.path.basename(x))[0]))
print(f"找到 {len(image_path)} 张图片:")
for img in image_path:
    print(img)


model = YOLO(weight_path)
# a = model.predict(image_path, show=True, classes=None, conf=0.3, save=True, half=False, imgsz=(1920, 1080), iou=0.3)
a = model.predict(image_path, show=True, classes=None, conf=0.65, save=True, half=False, imgsz=(1920, 1080), iou=0.3)
# print(a[0].boxes.xyxy.tolist())
